export function debounce<T extends (...args: any[]) => any>(fn: T, wait = 200) {
  let timer: number | undefined;
  return function(this: any, ...args: Parameters<T>) {
    const ctx = this;
    if (timer) clearTimeout(timer);
    // @ts-ignore
    timer = setTimeout(() => fn.apply(ctx, args), wait) as any;
  } as T;
}
